package org.swxjava.locator;

import org.swxjava.util.BeanUtils;
import org.swxjava.util.Log;
import org.swxjava.util.LogFactory;
import org.swxjava.util.MessageBundle;

public class NewServiceLocator implements ServiceLocator {

	private static final Log LOG = LogFactory.getLog(NewServiceLocator.class);

	/** instanciation target class */
	private Class targetClass = null;

	/**
	 * What sort of class do we instanciate?
	 * 
	 * @param classname
	 *            The name of the class
	 */
	public void setClass(String classname) {
		targetClass = BeanUtils.getClassForName(classname);
	}

	public Object getInstance() throws InstantiationException {
		try {
			return targetClass.newInstance();
		} catch (IllegalAccessException ex) {
			throw new InstantiationException(MessageBundle.getString("ServiceLocator.IllegalAccess", targetClass));
		}
	}
}
